procedure TForm1.Button1Click(Sender: TObject);
var
  FFileHandle: THandle; 
  FMapHandle: THandle; 
  FFileSize: Integer;     
  FData: PByte; 
  PData: PChar;
begin
if not FileExists('C:\WORK\data.txt') then
   raise Exception.Create('File does not exist.')
else
   FFileHandle := FileOpen('C:\WORK\data.txt',
                                                    fmOpenReadWrite);


if FFileHandle = INVALID_HANDLE_VALUE then
   raise Exception.Create('Failed to 
                                                   open or create file');
try

FFileSize := GetFileSize(FFileHandle, Nil);
FMapHandle := CreateFileMapping(FFileHandle,nil,
                                                               PAGE_READWRITE, 0, 
                                                               FFileSize, nil);
if FMapHandle = 0 then
   raise Exception.Create('Failed to create
                                                                 file mapping');
finally
	CloseHandle(FFileHandle);
end;

try
	FData := MapViewOfFile(FMapHandle, 
                                                FILE_MAP_ALL_ACCESS, 0,
                                                0,FFileSize);

	if FData = Nil then
		raise Exception.Create('Failed to map 
                                                                   view of file');
finally
	CloseHandle(FMapHandle);
end;

try

PData := PChar(FData); 
inc(PData, FFileSize);
PData^ := #0;
StrUpper(PChar(FData));

finally
UnmapViewOfFile(FData);
end;
end;
